﻿CREATE TABLE [dbo].[Task]
(
	[Id] INT NOT NULL PRIMARY KEY IDENTITY, 
    [Name] NVARCHAR(45) NOT NULL, 
    [Description] NVARCHAR(255) NULL, 
    [EndDate] DATETIME NOT NULL, 
    [Notification] DATETIME NULL, 
    [Notified] BIT NOT NULL DEFAULT 0, 
    [ShowInCalendar] BIT NOT NULL DEFAULT 0, 
    [Progress] INT NULL, 
    [ProjectId] INT NOT NULL, 
    [PriorityId] INT NOT NULL, 
	[ParentId] int null CONSTRAINT [FK_Task_Task_Id] FOREIGN KEY ([Id]) REFERENCES [Task]([Id]),
    CONSTRAINT [FK_Task_Project_Id] FOREIGN KEY ([ProjectId]) REFERENCES [Project]([Id]), 
    CONSTRAINT [FK_Task_Priority_Id] FOREIGN KEY ([PriorityId]) REFERENCES [Priority]([Id])    
)

GO

CREATE INDEX [IX_Task_ProjectId] ON [dbo].[Task] ([ProjectId])

GO

CREATE INDEX [IX_Task_PriorityId] ON [dbo].[Task] ([PriorityId])
